#删除原容器

echo "begin stop and delete old portainer......"
docker stop cqj-zookeeper && docker rm cqj-zookeeper
docker stop cqj-kafka && docker rm cqj-kafka
echo "=======================rm over=============================="

# pull portainer images
echo "=======================start pull portainer images=============================="
docker pull wurstmeister/zookeeper
docker wurstmeister/kafka
echo "=======================pull end.=============================="


#build new portainer container
echo "=======================start build portainer container=============================="
# zookeeper
docker run -d \
--network=bridge-chen \
--ip 172.20.1.5 \
-p 2181:2181 \
-v '/etc/localtime:/etc/localtime' \
--restart=always \
--log-driver json-file \
--log-opt max-size=100m \
--log-opt max-file=2  \
--restart=always \
--privileged=true \
--name='cqj-zookeeper' \
wurstmeister/zookeeper

# kafka
docker run -d \
--network=bridge-chen \
--ip 172.20.1.6 \
-p 9092:9092 \
-e 'KAFKA_BROKER_ID'='0' \
-e 'KAFKA_ZOOKEEPER_CONNECT'='172.20.1.5:2181' \
-e 'KAFKA_ADVERTISED_HOST_NAME'='10.0.0.217' \
-e 'KAFKA_ADVERTISED_PORT'='9092' \
--restart=always \
--privileged=true \
--name='cqj-kafka' \
wurstmeister/kafka
echo "=======================build end.=============================="
